package com.kingsalert.kingsalert.analytics.data_sdk.services;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.content.ContextCompat;

import com.google.gson.Gson;
import com.kingsalert.kingsalert.analytics.data_sdk.beans.ASHdwBn;
import com.kingsalert.kingsalert.analytics.data_sdk.util.ASGeneralUtil;
import com.kingsalert.kingsalert.analytics.data_sdk.util.ASHarewareUtil;
import com.kingsalert.kingsalert.analytics.data_sdk.util.ASNetworkUtil;
import com.kingsalert.kingsalert.analytics.data_sdk.util.ASUtil;

public class ASHdwIfo {

    public static ASHdwBn getDatas(final Context paramContext) {
        ASHdwBn bean = new ASHdwBn();
        if (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(paramContext, Manifest.permission.READ_PHONE_STATE)) {
            try {
                bean.setPhoneType(ASGeneralUtil.getPhoneType(paramContext));
                bean.setVersionCode(ASGeneralUtil.getVersionCode(paramContext));
                bean.setVersionName(ASGeneralUtil.getVersionName(paramContext));
                bean.setAoidId(ASGeneralUtil.getAndroidID(paramContext));
                bean.setTelephony(ASGeneralUtil.getSimOperatorName(paramContext));
                bean.setIsVpn(ASNetworkUtil.getVpnState(paramContext));
                bean.setIsPxyPt(ASNetworkUtil.getIsWifiProxy(paramContext));
                bean.setIsDebug(ASGeneralUtil.getIsDebug(paramContext));
                bean.setSState(ASGeneralUtil.getSimCardState(paramContext));
                bean.setRot(ASHarewareUtil.getIsRoot(paramContext));
                bean.setPysSize(ASHarewareUtil.getPhySicalSize(paramContext));
                bean.setDisplayLanguage(ASGeneralUtil.getDisplayLanguage(paramContext));
                bean.setIso3Language(ASGeneralUtil.getIso3Language(paramContext));
                bean.setIso3Country(ASGeneralUtil.getIso3Country(paramContext));
                bean.setNetworkOperatorName(ASGeneralUtil.getSimOperatorName(paramContext));
                bean.setNetworkType(ASGeneralUtil.getNetworkType(paramContext));
                bean.setTimeZoneId(ASGeneralUtil.getTimeZoneId(paramContext));
                bean.setElapsedRealtime(ASGeneralUtil.getElapsedRealtime(paramContext));
                bean.setSensorList(ASHarewareUtil.getSensorList(paramContext));
                bean.setLastBootTime(ASGeneralUtil.getLastBootTime(paramContext));
                bean.setRootJailbreak(ASHarewareUtil.getIsRoot(paramContext));
                bean.setKeyboard(ASHarewareUtil.getKeyboard(paramContext));
                bean.setIsSimulator(ASHarewareUtil.getIsSimulator(paramContext));
                bean.setDbm(ASHarewareUtil.getMobileDbm(paramContext));
                bean.setPhoneNumber(ASGeneralUtil.getPhoneNumber(paramContext));

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return bean;
    }

    public static String getZipString(Context paramContext) {
        String zipString = "";
        try {
            ASHdwBn infoBean = getDatas(paramContext);
            String result = new Gson().toJson(infoBean).trim();
            zipString = ASUtil.stringToGZIP(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return zipString;
    }
}
